package com.dyz.leetcode._05_sort;

public class _secondMaxNumber {
    //找到第二大的元素
    public int getSecondMax(int[] nums) {
        int first = Integer.MIN_VALUE;
        int second = Integer.MIN_VALUE;
        for (int num:nums){
            if(num>first){
                second = first;
                first = num;
            }else if(num>second){
                second = num;
            }
        }
        return second;
    }
}
